import java.io.*;
import java.util.*;

public class HotDog {
	public static void main(String args[]){
		try{
			Scanner sc = new Scanner(new File("B-small-practice.in"));//入力ファイル
			PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(new File("solve.in"))));//出力ファイル
			int T = sc.nextInt();//ループ回数
			for(int i=1;i<=T;i++){
				int C = sc.nextInt();
				int D = sc.nextInt();
				int[] P = new int[C];
				int[] V = new int[C];
				int vsum = 0;
				int pmin = 0;
				int pmax = 0;
				for(int j=0;j<C;j++){
					P[j]=sc.nextInt();
					V[j]=sc.nextInt();
					vsum += V[j];
					if(pmin>P[j])pmin=P[j];
					if(pmax<P[j])pmax=P[j];
				}
				double result =(double)((vsum-1)*D) - (double)pmax-(double)(pmax+pmin)/2.0;
				pw.println("Case #"+i+": "+result);//出力
			}
			pw.close();
		}catch(FileNotFoundException e){
			System.out.println(e);
		}catch(IOException e){
			System.out.println(e);			
		}
	}

}
